package com.xpgk.mvc.brefund;


import java.util.List;
import java.util.Map;

import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.tx.Tx;
import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.bentryRegister.Customer;
import com.xpgk.mvc.productOutin.ProductOutin;
import com.xpgk.mvc.user.User;

public class BrefundController extends  BaseController{
	
	
	private BrefundService  brefundService;
	public  void   index()
	{	
		setAttr("organids", getCUserOrganIds());
		User  user=User.dao.findById(getCUserIds());
		setAttr("user",user);
		
		render("Brefund.html");
	}
	/**获取顾客可 退款产品
	 *
	 */
	public  void  getReturnProduct()
	{	
		String customerIds=getPara("customerIds");
		Map<String, Object> mm  = brefundService.getReturnProduct(customerIds,getCUserOrganIds());
		renderJson(mm);
	}
	/**确认退款
	 * 
	 */
	@Before(Tx.class)
	public  void  saveReturn()
	{
		List<ProductReturn> prList = getModels(ProductReturn.class);
		Customer      c=getModel(Customer.class);
		String userIds=getPara("userIds");
		String result=getPara("result");
		String other=getPara("other");
		String operatorIds=getCUserIds();//操作者ids
		String msg=brefundService.saveReturn(prList,c,userIds,result,other,operatorIds,getCUserOrganIds());
		renderText(msg);
		
	}
}

